home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™ 1987-1994 / MacHack™ '88 / Other stuff / CLIP stuff / clipdemo src / ClipDemo.c next >
Encoding:
C/C++ Source or Header  |  1986-05-25  |  21.1 KB  |  679 lines  |  [TEXT/FstE]

  1. /*                          C Extender - ClipDemo2                      */
  2. /*                          Aztec C compiler 1.06g                      */
  3.  
  4. /* David A. Feldt                                               2/27/86 */
  5. /* David A. Feldt                                               3/18/86 */
  6. /* David A. Feldt        found maintain cursor bug              3/19/86 */
  7. /* David A. Feldt        fixed bugs and added digitron lines    3/20/86 */
  8. /* Joseph Sitomer        added calls to math. model stuff       3/24/86 */
  9. /* David A. Feldt        removed journal window and code        5/16/86 */
  10. /* David A. Feldt        added terminal code to MICOR window    5/18/86 */
  11.  
  12. #include    "clipinclude.h"
  13.  
  14.  
  15. main()
  16. {
  17.     int         i;
  18.  
  19.     ClipInit();                     /* Clip specific initialize routine */
  20.     TermInit();                     /* init data structures, menus and windows  */
  21.     
  22.     do {        
  23.         do {
  24.             if (micor == TRUE) {
  25.                 CheckPort();        /* take care of data arriving at comm port  */
  26.             }
  27.             SystemTask();           /* slice of cpu time to desk accessories*/                                
  28.         } while (!GetNextEvent(everyEvent,&Event)); /* repeat until event   */
  29.         HandleEvent(&Event,&whatHappened); /* get event info from extender  */
  30.  
  31.         if (whatHappened.MenuNum > 0) {
  32.             HndlMenus(&whatHappened);
  33.         }
  34.         if (whatHappened.WhichControl != NULL) {
  35.             HndlCntrls(&whatHappened);
  36.         }
  37.         if (whatHappened.WhichWindow == dWindPtr && digitron == TRUE && Event.what == mouseDown) {
  38.             HndlDig(&whatHappened,&Event);
  39.         }
  40.         if (micor == TRUE) {
  41.             HndlChar(LoWord(Event.message));
  42.         }
  43.  
  44.     } while (!(whatHappened.MenuH == fileMenu && whatHappened.ItemNum == 12));
  45. }
  46.  
  47. void  HndlDig(ES,EV)
  48. EventStuff        *ES;
  49. EventRecord       *EV;
  50. {
  51.     Point           pt;
  52.     Rect            tRect;
  53.     INT             width = apRect.right - apRect.left;
  54.     INT                height = apRect.top - apRect.bottom;
  55.     char            string[16];
  56.     INT             apxo = apRect.left + (width / 2);
  57.     INT             apyo = apRect.top - (height / 2);
  58.     INT             latxo = latRect.left + (width / 2);
  59.     INT             latyo = latRect.top - (height / 2);
  60.     
  61.     
  62.  
  63.     if (ES->WindowPart == inContent) {
  64.         SetPort(dWindPtr);    
  65.         pt = EV->where;
  66.         GlobalToLocal(&pt);
  67.         if (PtInRect(pass(pt),&apRect)) {
  68.             SetRect(&tRect,pt.h,pt.v,pt.h + 2,pt.v + 2);
  69.             FrameOval(&tRect);
  70.             
  71.             ptvect0[0] = (FLOAT)(pt.h - apxo);
  72.             ptvect0[1] = (FLOAT)(pt.v - apyo);
  73.             ptvect0[2] = (FLOAT)(APDMAX - distAP);
  74.             mxmul(aptopat,3,3,ptvect0,3,1,ptvectt);
  75.             ptvect0[0] = ptvectt[0];
  76.             ptvect0[1] = ptvectt[1];
  77.             ptvect0[2] = ptvectt[2];
  78.             mxmul(pattolat,3,3,ptvect0,3,1,ptvectt);
  79.             mf = MagFact(ptvectt[2],(LATDMAX - distLAT));
  80.             ptvectt[0] *= mf;
  81.             ptvectt[1] *= mf;
  82.             
  83.             fsvect0[0] = 0;
  84.             fsvect0[1] = 0;
  85.             fsvect0[2] =  -ISOCTOFS;
  86.             mxmul(aptopat,3,3,fsvect0,3,1,fsvectt);
  87.             fsvect0[0] = fsvectt[0];
  88.             fsvect0[1] = fsvectt[1];
  89.             fsvect0[2] = fsvectt[2];
  90.             mxmul(pattolat,3,3,fsvect0,3,1,fsvectt);
  91.             mf = MagFact(fsvectt[2],(LATDMAX - distLAT));
  92.             fsvectt[0] *= mf;
  93.             fsvectt[1] *= mf;
  94.  
  95.             ClipRect(&latRect);
  96.             MoveTo((INT)(latxo + ptvectt[0]),(INT)(latyo + ptvectt[1]));
  97.             LineTo((INT)(latxo + fsvectt[0]),(INT)(latyo + fsvectt[1]));
  98.             ClipRect(&(dWindPtr->portRect)); 
  99.         }
  100.         else
  101.             if (PtInRect(pass(pt),&latRect)) {
  102.                 SetRect(&tRect,pt.h,pt.v,pt.h + 2,pt.v + 2);
  103.                 FrameOval(&tRect);
  104.             
  105.                 ptvect0[0] = (FLOAT)(pt.h - latxo);
  106.                 ptvect0[1] = (FLOAT)(pt.v - latyo);
  107.                 ptvect0[2] = (FLOAT)(LATDMAX - distLAT);
  108.                 mxmul(lattopat,3,3,ptvect0,3,1,ptvectt);
  109.                 ptvect0[0] = ptvectt[0];
  110.                 ptvect0[1] = ptvectt[1];
  111.                 ptvect0[2] = ptvectt[2];
  112.                 mxmul(pattoap,3,3,ptvect0,3,1,ptvectt);
  113.                 mf = MagFact(ptvectt[2],(APDMAX - distAP));
  114.                 ptvectt[0] *= mf;
  115.                 ptvectt[1] *= mf;
  116.                 
  117.                 fsvect0[0] = 0;
  118.                 fsvect0[1] = 0;
  119.                 fsvect0[2] =  -ISOCTOFS;
  120.                 mxmul(lattopat,3,3,fsvect0,3,1,fsvectt);
  121.                 fsvect0[0] = fsvectt[0];
  122.                 fsvect0[1] = fsvectt[1];
  123.                 fsvect0[2] = fsvectt[2];
  124.                 mxmul(pattoap,3,3,fsvect0,3,1,fsvectt);
  125.                 mf = MagFact(fsvectt[2],(APDMAX - distAP));
  126.                 fsvectt[0] *= mf;
  127.                 fsvectt[1] *= mf;
  128.                 
  129.                 ClipRect(&apRect);
  130.                 MoveTo((INT)(apxo + ptvectt[0]),(INT)(apyo + ptvectt[1]));
  131.                 LineTo((INT)(apxo + fsvectt[0]),(INT)(apyo + fsvectt[1]));
  132.                 ClipRect(&(dWindPtr->portRect)); 
  133.             }
  134.         }
  135.  
  136. }
  137.  
  138. DOUBLE MagFact(zobj,zisoc)
  139. DOUBLE          zobj;
  140. INT             zisoc;
  141. {
  142.     return ((DOUBLE) (zisoc + ISOCTOFS) / ((DOUBLE) ISOCTOFS + zobj));
  143. }
  144.     
  145.  
  146. void HndlCntrls(ES)
  147. EventStuff      *ES;
  148. {
  149.     if (ES->WhichWindow == BWindPtr)
  150.         HndlBICOR(ES);
  151. }
  152.  
  153. void HndlBICOR(ES)
  154. EventStuff        *ES;
  155. {
  156.       char              string[16];
  157.       long              value;
  158.  
  159.       if (ES->WhichControl == apcntrls[0]) {
  160.             value = (long)GetCtlVal(apcntrls[0]);
  161.             NumToString(value - APAMIN,string);
  162.             SetCTitle(apcntrls[3],string);
  163.             rotAlphAP(value - APAMIN);
  164.       }
  165.       if (ES->WhichControl == apcntrls[1]) {
  166.             value = (long)GetCtlVal(apcntrls[1]);
  167.             NumToString(value - APBMIN,string);
  168.             SetCTitle(apcntrls[4],string);
  169.             rotBetaAP(value - APBMIN);
  170.       }
  171.       if (ES->WhichControl == apcntrls[2]) {
  172.             value = (long)GetCtlVal(apcntrls[2]);
  173.             NumToString(APDMAX - value,string);
  174.             SetCTitle(apcntrls[5],string);
  175.             distAP = value;
  176.       }
  177.       if (ES->WhichControl == apcntrls[6]) {
  178.             rotAlphAP(0);
  179.             rotBetaAP(0);
  180.             distAP = 0;
  181.             NumToString((long)alphaAP,string);
  182.             SetCTitle(apcntrls[3],string);
  183.             SetCtlValue(apcntrls[0],alphaAP + APAMIN);
  184.             NumToString((long)betaAP,string);
  185.             SetCTitle(apcntrls[4],string);
  186.             SetCtlValue(apcntrls[1],betaAP + APBMIN);
  187.             NumToString((long)(APDMAX - distAP),string);
  188.             SetCTitle(apcntrls[5],string);
  189.             SetCtlValue(apcntrls[2],distAP);
  190.       }
  191.       if (ES->WhichControl == latcntrls[0]) {
  192.             value = (long)GetCtlVal(latcntrls[0]);
  193.             NumToString(value - LATAMIN,string);
  194.             SetCTitle(latcntrls[3],string);
  195.             rotAlphLAT(value - LATAMIN);
  196.       }
  197.       if (ES->WhichControl == latcntrls[1]) {
  198.             value = (long)GetCtlVal(latcntrls[1]);
  199.             NumToString(value - LATBMIN,string);
  200.             SetCTitle(latcntrls[4],string);
  201.             rotBetaLAT(value - LATBMIN);
  202.       }
  203.       if (ES->WhichControl == latcntrls[2]) {
  204.             value = (long)GetCtlVal(latcntrls[2]);
  205.             NumToString(LATDMAX - value,string);
  206.             SetCTitle(latcntrls[5],string);
  207.             distLAT = value;
  208.       }
  209.       if (ES->WhichControl == latcntrls[6]) {
  210.             rotAlphLAT(0);
  211.             rotBetaLAT(0);
  212.             distLAT = 0;
  213.             NumToString((long)alphaLAT,string);
  214.             SetCTitle(latcntrls[3],string);
  215.             SetCtlValue(latcntrls[0],alphaLAT + LATAMIN);
  216.             NumToString((long)betaLAT,string);
  217.             SetCTitle(latcntrls[4],string);
  218.             SetCtlValue(latcntrls[1],betaLAT + LATBMIN);
  219.             NumToString((long)(LATDMAX - distLAT),string);
  220.             SetCTitle(latcntrls[5],string);
  221.             SetCtlValue(latcntrls[2],distLAT);
  222.       }
  223.       mkmxa(alphaAP,betaAP,aptopat,pattoap);
  224.       mkmxl(alphaLAT,betaLAT,lattopat,pattolat);
  225.       mkmxii(pattoap,aptopat,pattolat,lattopat,aptolat,lattoap);
  226.       return();
  227. }
  228.  
  229. void        rotAlphAP(value)
  230. long    value;
  231.  
  232. {
  233.     if (alphaAP < (INT) value) {
  234.         for ( ; alphaAP <= (INT) value; alphaAP += ((value - alphaAP > 5) ? 5 : 1))
  235.             drawAParcs();
  236.         alphaAP -= 1;
  237.     }
  238.     else if (alphaAP > (INT) value) {
  239.         for ( ; alphaAP >= (INT) value; alphaAP -= ((alphaAP - value > 5) ? 5 : 1))
  240.             drawAParcs();
  241.         alphaAP += 1;
  242.     }
  243. }
  244.  
  245. void        rotBetaAP(value)
  246. long    value;
  247.  
  248. {
  249.     if (betaAP < (INT) value) {
  250.         for (; betaAP <= (INT) value; betaAP += ((value - betaAP > 5) ? 5 : 1))
  251.             drawAParcs();
  252.         betaAP -= 1;
  253.     }
  254.     else if (betaAP > (INT) value) {
  255.         for (; betaAP >= (INT) value; betaAP -= ((betaAP - value > 5) ? 5 : 1))
  256.             drawAParcs();
  257.         betaAP += 1;
  258.     }
  259. }
  260.  
  261. void        rotAlphLAT(value)
  262. long    value;
  263.  
  264. {
  265.     if (alphaLAT < (INT) value) {
  266.         for (; alphaLAT <= (INT) value; alphaLAT += (value - alphaLAT > 5) ? 5 : 1)
  267.             drawLATarcs();
  268.         alphaLAT -= 1;
  269.     }
  270.     else if (alphaLAT > (INT) value) { 
  271.         for (; alphaLAT >= (INT) value; alphaLAT -= (alphaLAT - value > 5) ? 5 : 1)
  272.             drawLATarcs();
  273.         alphaLAT += 1;
  274.     }
  275. }
  276.  
  277. void        rotBetaLAT(value)
  278. long    value;
  279.  
  280. {
  281.     if (betaLAT < (INT) value) {
  282.         for (; betaLAT <= (INT) value; betaLAT += (value - betaLAT > 5) ? 5 : 1)
  283.             drawLATarcs();
  284.         betaLAT -= 1;
  285.     }
  286.     else if (betaLAT > (INT) value) {
  287.         for (; betaLAT >= (INT) value; betaLAT -= (betaLAT - value > 5) ? 5 : 1)
  288.             drawLATarcs();
  289.         betaLAT += 1;
  290.     }
  291. }
  292.  
  293.  
  294. WindowPtr  MkBICORWindow(tlcorner)
  295. Point       tlcorner;
  296. {
  297.       Rect        tempRect;
  298.       WindowPtr   wPtr;
  299.       char        string[16];
  300.       
  301.       SetRect(&tempRect,tlcorner.h,tlcorner.v,tlcorner.h + 350,tlcorner.v + 300);
  302.       wPtr = CreateWindow(&BICORWind,&tempRect,"\PBICOR window",16,TRUE,TRUE,FALSE,FALSE,FALSE);
  303.       SetRect(&tempRect,10,125,90,141);
  304.       apcntrls[0] = CreateScrollBar(wPtr,&tempRect,alphaAP + APAMIN,0,APAMIN + APAMAX);
  305.       SetRect(&tempRect,160,125,240,141);
  306.       apcntrls[1] = CreateScrollBar(wPtr,&tempRect,betaAP + APBMIN,0,APBMIN + APBMAX);
  307.       SetRect(&tempRect,117,20,133,80);
  308.       apcntrls[2] = CreateScrollBar(wPtr,&tempRect,distAP,0,APDMAX - APDMIN);
  309.       SetRect(&tempRect,30,105,70,121);
  310.       NumToString((long)alphaAP,string);
  311.       apcntrls[3] = CreatePushButton(wPtr,&tempRect,string);
  312.       SetRect(&tempRect,180,105,220,121);
  313.       NumToString((long)betaAP,string);
  314.       apcntrls[4] = CreatePushButton(wPtr,&tempRect,string);
  315.       SetRect(&tempRect,110,90,140,106);
  316.       NumToString((long)(APDMAX - distAP),string);
  317.       apcntrls[5] = CreatePushButton(wPtr,&tempRect,string);
  318.       SetRect(&tempRect,270,20,330,40);
  319.       apcntrls[6] = CreatePushButton(wPtr,&tempRect,"\PHome AP");
  320.       SetRect(&tempRect,270,50,330,70);
  321.       apcntrls[7] = CreatePushButton(wPtr,&tempRect,"\PProg #1");
  322.       SetRect(&tempRect,270,80,330,100);
  323.       apcntrls[8] = CreatePushButton(wPtr,&tempRect,"\PProg #2");
  324.       SetRect(&tempRect,270,110,330,130);
  325.       apcntrls[9] = CreatePushButton(wPtr,&tempRect,"\PProg #3");
  326.                                                       /* lat controls definitions */
  327.       SetRect(&tempRect,10,275,90,291);
  328.       latcntrls[0] = CreateScrollBar(wPtr,&tempRect,alphaLAT + LATAMIN,0,LATAMIN + LATAMAX);
  329.       SetRect(&tempRect,160,275,240,291);
  330.       latcntrls[1] = CreateScrollBar(wPtr,&tempRect,betaLAT + LATBMIN,0,LATBMIN + LATBMAX);
  331.       SetRect(&tempRect,117,170,133,230);
  332.       latcntrls[2] = CreateScrollBar(wPtr,&tempRect,distLAT,0,LATDMAX - LATDMIN);
  333.       SetRect(&tempRect,30,255,70,271);
  334.       NumToString((long)alphaLAT,string);
  335.       latcntrls[3] = CreatePushButton(wPtr,&tempRect,string);
  336.       SetRect(&tempRect,180,255,220,271);
  337.       NumToString((long)betaLAT,string);
  338.       latcntrls[4] = CreatePushButton(wPtr,&tempRect,string);
  339.       SetRect(&tempRect,110,240,140,256);
  340.       NumToString((long)(LATDMAX - distLAT),string);
  341.       latcntrls[5] = CreatePushButton(wPtr,&tempRect,string);
  342.       SetRect(&tempRect,270,170,330,190);
  343.       latcntrls[6] = CreatePushButton(wPtr,&tempRect,"\PHomeLAT");
  344.       SetRect(&tempRect,270,200,330,220);
  345.       latcntrls[7] = CreatePushButton(wPtr,&tempRect,"\PProg #1");
  346.       SetRect(&tempRect,270,230,330,250);
  347.       latcntrls[8] = CreatePushButton(wPtr,&tempRect,"\PProg #2");
  348.       SetRect(&tempRect,270,260,330,280);
  349.       latcntrls[9] = CreatePushButton(wPtr,&tempRect,"\PProg #3");
  350.       return(wPtr);       
  351. }
  352.  
  353. void ClipInit()
  354. {
  355.     XTendInit();                                /* extender initialization routine      */
  356.     StdMenus(&appleMenu,&fileMenu,&editMenu);   /* set up standard menus  */
  357.     toolMenu = BuildMenu(20,"\PTools","\PBICOR;MICOR;Digitron");
  358.     digitron = FALSE;
  359.     Bicor = FALSE;
  360.     EnableItem(appleMenu,1);
  361.     ShowAboutBox();
  362.     BICORValInit();
  363. }
  364.  
  365. void BICORValInit()
  366. {
  367.     alphaAP = 0;
  368.     betaAP = 0;
  369.     distAP = 0;
  370.     alphaLAT = 0;
  371.     betaLAT = 0;
  372.     distLAT = 0;
  373.     
  374.     mkmxa(alphaAP,betaAP,aptopat,pattoap);
  375.     mkmxl(alphaLAT,betaLAT,lattopat,pattolat);
  376.     mkmxii(aptopat,pattoap,lattopat,pattolat,aptolat,lattoap);
  377. }
  378.  
  379. void HndlMenus(ES)
  380. EventStuff      *ES;
  381. {
  382.     WData       WD;
  383.     int         i;       
  384.     static int  bauds[] = {0x17c, 0xbd, 0x5e, 0x3e, 0x2e, 0x1e, 0x16, 0x0e, 0x0a, 0x04};
  385.       
  386.     switch (ES->MenuNum) {
  387.         case 11:                                        /* APPLE menu     */
  388.             if (ES->ItemNum == 1)
  389.                 ShowAboutBox();
  390.             break;
  391.         case 20:                                        /* TOOLS menu       */
  392.             switch (ES->ItemNum) {
  393.                     case 1:                             /* BICOR option     */
  394.                         if (Bicor == FALSE)
  395.                               InitBICOR();
  396.                         else
  397.                               KillBICOR();
  398.                         break;
  399.                     case 2:                             /* MICOR option     */
  400.                         if (micor == FALSE)
  401.                               InitMicor();
  402.                         else
  403.                               KillMicor();
  404.                         break;
  405.                     case 3:                             /* Digitron option  */
  406.                         if (digitron == FALSE)
  407.                               InitDigitron();
  408.                         else
  409.                               KillDigitron();
  410.                         break;
  411.             }
  412.             break;
  413.         case 21:                                /* if the Baud menu was selected    */
  414.             for (i=1;i<11;i++)                  /* remove checks on all items       */
  415.                 CheckItem(baudMenu, i, 0);      
  416.             CheckItem(baudMenu,whatHappened.ItemNum,TRUE);/* check the item selected*/
  417.             Port->baud = bauds[whatHappened.ItemNum - 1]; /* set port baud rate     */
  418.             setupport();                        /* reinitialize port settings       */
  419.             break;
  420.         case 22:                                /* if the Port menu was selected    */
  421.             CheckItem(portMenu, 1, 0);
  422.             CheckItem(portMenu, 2, 0);
  423.             switch(whatHappened.ItemNum) {
  424.                 case 1:
  425.                     switchport(&PortA);
  426.                     CheckItem(portMenu, 1, TRUE);
  427.                              break;
  428.                 case 2:
  429.                     switchport(&PortB);
  430.                     CheckItem(portMenu, 2, TRUE);
  431.                     break;
  432.             }
  433.             break;
  434.     }
  435. }
  436.         
  437. void        InitMicor()
  438. {
  439.     if (micor == FALSE) {
  440.         ShowWindow(mWindPtr);
  441.         SelectWindow(mWindPtr);
  442.         SetPort(mWindPtr);
  443.         micor = TRUE;
  444.     }
  445. }
  446.  
  447. void        KillMicor()
  448. {
  449.       if (micor == TRUE) {
  450.             HideWindow(mWindPtr);
  451.             micor = FALSE;
  452.       }
  453. }
  454.  
  455. void        PicBICOR()
  456. {
  457.       PicHandle   picHndl;
  458.       Rect        R;
  459.       
  460.       picHndl = OpenPicture(&(screenBits.bounds));
  461.             
  462.             SetRect(&R,5,5,95,95);
  463.             FrameOval(&R);
  464.  
  465.             SetRect(&R,155,5,245,95);
  466.             FrameOval(&R);
  467.             
  468.             SetRect(&R,5,155,95,245);
  469.             FrameOval(&R);            
  470.             
  471.             SetRect(&R,155,155,245,245);
  472.             FrameOval(&R);
  473.             
  474.             SetRect(&R,260,10,340,290);
  475.             FrameRoundRect(&R,16,16);
  476.             
  477.             MoveTo(110,125);
  478.             DrawString("\PAP arm");
  479.             MoveTo(105,275);
  480.             DrawString("\PLAT arm");
  481.       ClosePicture();
  482.       SetPort(BWindPtr);
  483.       DrawPicture(picHndl,&(screenBits.bounds));
  484.       SetWPic(BWindPtr,picHndl);
  485.       drawAParcs();
  486.       drawLATarcs();
  487. }
  488.  
  489. void    drawAParcs()
  490. {
  491.     Rect    R;
  492.     DOUBLE  sinb,cosb;
  493.     INT     height;
  494.     
  495.     cosb = cos((DOUBLE) betaAP * Pi / 180.0);
  496.     sinb = sin((DOUBLE) betaAP * Pi / 180.0);
  497.     height = (INT) 25.0 * cosb;
  498.     
  499.     SetRect(&R,25,25,75,75);
  500.     EraseRect(&R);
  501.     PenSize(3,3);
  502.     if (height >= 0) {
  503.         if (height < 3) height = 3;
  504.         SetRect(&R,25,50 - height,75, 50 + height);
  505.         FrameArc(&R,alphaAP + 180,180);
  506.     }
  507.     else {
  508.         if (height > -3) height = -3;
  509.         SetRect(&R,25,50 + height,75, 50 - height);
  510.         FrameArc(&R,180 - alphaAP,180);
  511.     }
  512.  
  513.     SetRect(&R,172,22,228,78);
  514.     EraseRect(&R);
  515.     MoveTo(200 + (INT) (25.0 * sinb),50 + (INT) (25.0 * cosb));
  516.     LineTo(200 - (INT) (25.0 * sinb),50 - (INT) (25.0 * cosb));
  517.     PenSize(1,1);
  518. }
  519.  
  520. void    drawLATarcs()
  521.  
  522. {
  523.     Rect    R;
  524.     DOUBLE  sinb,cosb;
  525.     INT     width;
  526.     
  527.     cosb = cos((DOUBLE) betaLAT * Pi / 180.0);
  528.     sinb = sin((DOUBLE) betaLAT * Pi / 180.0);
  529.     width = (INT) 25.0 * cosb;
  530.     
  531.     SetRect(&R,25,175,75,225);
  532.     EraseRect(&R);            
  533.     PenSize(3,3);
  534.     SetRect(&R,50 - width,175,50 + width,225);
  535.     FrameArc(&R,alphaLAT + 270,180);
  536.                                           
  537.     SetRect(&R,172,172,228,228);
  538.     EraseRect(&R);
  539.     MoveTo(200 + (INT) (25.0 * cosb),200 + (INT) (25.0 * sinb));
  540.     LineTo(200 - (INT) (25.0 * cosb),200 - (INT) (25.0 * sinb));
  541.     PenSize(1,1);
  542. }
  543.  
  544.  
  545. void    HandleUpdateException (wPtr)
  546.  
  547. WindowPtr   wPtr;
  548.  
  549. {
  550.  
  551.     GrafPtr     tempport;
  552.     
  553.     GetPort (&tempport);
  554.     SetPort(wPtr);
  555.     BeginUpdate (wPtr);
  556.     GrafUpdate (&(wPtr->portRect),wPtr);
  557.     DrawControls (wPtr);
  558.     drawAParcs();
  559.     drawLATarcs();
  560.     EndUpdate(wPtr);
  561.     SetPort(tempport);
  562. }
  563.  
  564.  
  565. void        InitBICOR()
  566. {
  567.       Point        corner;
  568.  
  569.       if (Bicor == FALSE) {
  570.             corner.h = 30;          /* setpoint topleft */
  571.             corner.v = 50;
  572.             BWindPtr = MkBICORWindow(pass(corner));
  573.             SetUpdateException(BWindPtr,TRUE);
  574.             PicBICOR();
  575.             Bicor = TRUE;
  576.       }
  577. }
  578.  
  579. void        KillBICOR()
  580. {
  581.       if (Bicor == TRUE) {
  582.             KillWindow(BWindPtr);
  583.             Bicor = FALSE;
  584.       }
  585. }
  586.  
  587. void        InitDigitron()
  588. {
  589.       Rect        WRect;
  590.       Rect        tempRect;
  591.       PicHandle   tempPic;
  592.       char        string[16];
  593.  
  594.       ptvect0[0] = ptvect0[1] = ptvect0[2] = 0.;
  595.       ptvectt[0] = ptvectt[1] = ptvectt[2] = 0.;
  596.       fsvect0[0] = fsvect0[1] = fsvect0[2] = 0.;
  597.       fsvectt[0] = fsvectt[1] = fsvectt[2] = 0.;
  598.       if (digitron == FALSE) {
  599.             SetRect(&WRect,60,110,360,310);  /* set rect topleft & bottomright */
  600.             dWindPtr = CreateWindow(&dWind,&WRect,"\PDigitron window",0,TRUE,TRUE,FALSE,FALSE,FALSE);
  601.             SetPort(dWindPtr);
  602.             tempPic = OpenPicture(&(screenBits.bounds));
  603.                 SetRect(&apRect,10,10,110,110);
  604.                 SetRect(&latRect,130,10,230,110);
  605.                 FrameRect(&apRect);
  606.                 FrameRect(&latRect);
  607.                 MoveTo(40,130);
  608.                 DrawString("\PAP view");
  609.                 MoveTo(160,130);
  610.                 DrawString("\PLAT view");
  611.             ClosePic();
  612.             DrawPicture(tempPic,&(screenBits.bounds));
  613.             SetWPic(dWindPtr,tempPic);
  614.             digitron = TRUE;
  615.       }
  616. }
  617.  
  618. void        KillDigitron()
  619. {
  620.       if (digitron == TRUE) {
  621.             KillWindow(dWindPtr);
  622.             digitron = FALSE;
  623.       }
  624. }
  625.     
  626. void UserGoAway(theWindow)
  627. WindowPtr         theWindow;
  628. {
  629.       if ((micor == TRUE) && (theWindow == mWindPtr)) {
  630.             KillMicor();
  631.             return();
  632.       }
  633.       if ((digitron == TRUE) && (theWindow == dWindPtr)) {
  634.             KillDigitron();
  635.             return();
  636.       }
  637.       if ((Bicor == TRUE) && (theWindow == BWindPtr)) {
  638.             KillBICOR();
  639.             return();
  640.       }
  641. }
  642.         
  643. void ShowAboutBox()
  644. {
  645.       DialogPtr         DP;
  646.       int               itemHit;
  647.  
  648.                DP = GetNewDialog(128,NULL,NEG_ONE);   /* 'About' dialog was assigned #128 */
  649.                ShowWindow(DP);
  650.                ModalDialog(NULL,&itemHit);
  651.                DisposDialog(DP);
  652. }
  653.  
  654. INT     UserArrowInc(w,c,a)
  655. WindowPtr       w;
  656. ControlHandle   c;
  657. INT             a;
  658. {
  659.     INT             temp;
  660.     
  661.     if (w == BWindPtr) {
  662.         temp = (GetCtlMax(c) - GetCtlMin(c)) / 100 + 1;
  663.         return(temp);
  664.     }
  665. }
  666.  
  667. INT     UserPageInc(w,c,p)
  668. WindowPtr       w;
  669. ControlHandle   c;
  670. INT             p;
  671. {
  672.     INT             temp;
  673.     
  674.     if (w == BWindPtr) {
  675.         temp = (GetCtlMax(c) - GetCtlMin(c)) / 10 + 1;
  676.         return(temp);
  677.     }
  678. }
  679.